home *** CD-ROM | disk | FTP | other *** search
- Path: crl.crl.com!not-for-mail
- From: bobfry@crl.com (Robert Fry)
- Newsgroups: comp.lang.c
- Subject: Re: warning: possibly incorrect assignment
- Date: 9 Jan 1996 09:04:42 -0800
- Organization: CRL Dialup Internet Access
- Message-ID: <4cu77a$c8i@crl.crl.com>
- References: <Pine.OSF.3.91.960109091920.6447A-100000@io.UWinnipeg.ca>
- NNTP-Posting-Host: crl.com
-
- Bill Simpson <wsimpson@uwinnipeg.ca> writes:
-
- >I get the above warning when I compile code using the following
- >function. It flags the **** line.
-
- <snipping everything but the offending line>
-
- >**** while(fp=fopen(file_name,"r"))
-
- >How can I write this code so the compiler does not issue this warning?
- >Please don't suggest I just tell the compiler to shut up. In general
- >the warnings are useful. I do not want to just ignore the warning either.
- >I have the FAQ and haven't seen this discussed.
-
- The compiler is warning you that 'while' statements are normally true or
- false, and you might be accidentally doing an assignment where you want
- to do a comparison. The code is perfectly legal, if not as clear as possible.
-
- The only way I can think of to eliminate the warning is to change the
- line to two lines:
- fp = fopen( file_name, "r");
- while ( fp)
-
- Hope this helps!
- Bob
-